package com.caiden_micheal.dynamic.form_workflow.web;

import com.caiden_micheal.base.domain.AjxResult;
import com.caiden_micheal.dynamic.form_workflow.dto.*;
import com.caiden_micheal.dynamic.form_workflow.service.FormWorkflowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/formWorkflow")
public class FormWorkflowController {

    @Autowired
    private FormWorkflowService formWorkflowService;

    @PostMapping("/addFormWorkflow")
    public AjxResult addFormWorkflow(@RequestBody AddFormWorkflowDTO addFormWorkflowDTO) {
        return formWorkflowService.addFormWorkflow(addFormWorkflowDTO);
    }

    @PostMapping("/removeFormWorkflow")
    public AjxResult removeFormWorkflow(@RequestBody RemoveFormWorkflowDTO removeFormWorkflowDTO) {
        return formWorkflowService.removeFormWorkflow(removeFormWorkflowDTO);
    }

    @PostMapping("/findFormWorkflowPageQuery")
    public AjxResult findFormWorkflowPageQuery(@RequestBody FindFormWorkflowPageQueryDTO findFormWorkflowPageQueryDTO) {
        return AjxResult.success(formWorkflowService.findFormWorkflowByCondition(findFormWorkflowPageQueryDTO));
    }

    @PostMapping("/updateExplain")
    public AjxResult updateExplain(@RequestBody UpdateExplainDTO updateExplainDTO) {
        return formWorkflowService.updateExplain(updateExplainDTO);
    }

    @PostMapping("/findExistenceByFormIdOrWorkflowId")
    public AjxResult findExistenceByFormIdOrWorkflowId(@RequestBody FindExistenceByFormIdOrWorkflowIdDTO findExistenceByFormIdOrWorkflowIdDTO) {
        return formWorkflowService.findExistenceByFormIdOrWorkflowId(findExistenceByFormIdOrWorkflowIdDTO);
    }

    @PostMapping("/findFormWorkflowSelectData")
    public AjxResult findFormWorkflowSelectData(@RequestBody FindFormWorkflowSelectData findFormWorkflowSelectData) {
        return formWorkflowService.findFormWorkflowSelectData(findFormWorkflowSelectData);
    }
}
